
from subprocess import Popen, PIPE

class SysCall:
    def __init__(self, exec_: str = None):
        self._exec = exec_

        self._args: list = []

        self._error: str
        self._out: str
        self._input: any = None

    def _call(self):
        self._process = Popen( [self._exec] + self._args,
                                    stdin=PIPE,
                                    stdout=PIPE,
                                    stderr=PIPE,
                                    )

        self._out, self._error = self._process.communicate(input=self._input)

    def args(self, args: list):
        self._args = args

    def input(self, data: bytes):
        self._input = data

    def exec(self):
        self._call()

        if not self.get_error:
            return True
        else:
            return False

    def get_output(self):
        return self._out

    def get_error(self):
        return self._error
